<template>
  <div id="app">
    <keep-alive>
      <router-view  v-if="this.$route.meta.keepAlive" />
    </keep-alive>
    <router-view v-if="!this.$route.meta.keepAlive" />
	<loding-item v-show="LOADING"/>
  </div>
</template>

<script>
	import {mapState} from "vuex"
	import { initJsSDK } from "@/wechat";
	import lodingItem from '@/components/loding-item'
	import qs from "qs";
	import { redirectOCAuth,getWechatUser} from "@/api/index";
	export default{
		components:{
			lodingItem
		},
		data(){
			return{
				oldScrollTop: 0
			}
		},
		computed:{
		   ...mapState(['LOADING']),
		},
		async mounted(){
			initJsSDK()
			document.body.addEventListener("focusin", () => {
			  //软键盘弹起事件
			  /* 获取窗口滚动条高度 */
			  function getScrollTop() {
			    let scrollTop = 0;
			    if (document.documentElement && document.documentElement.scrollTop) {
			      scrollTop = document.documentElement.scrollTop;
			    } else if (document.body) {
			      scrollTop = document.body.scrollTop;
			    }
			    return scrollTop;
			  }
			  this.oldScrollTop = getScrollTop() || 0; // 记录当前滚动位置
			});
			
			document.body.addEventListener("focusout", () => {
			  //软键盘关闭事件
			  const ua = window.navigator.userAgent;
			  if (ua.indexOf("iPhone") > 0 || ua.indexOf("iPad") > 0) {
			    //键盘收起页面空白问题
			    document.body.scrollTop = this.oldScrollTop;
			    document.documentElement.scrollTop = this.oldScrollTop;
			  }
			});
			
		},
		
	}
</script>

<style lang="less">
@import "assets/public.css";
</style>
